package com.duoketech.model.product;
import com.alibaba.druid.sql.PagerUtils;
import com.duoketech.model.AbstractModel;
import com.duoketech.utils.PageUtil;

import java.util.List;

public class Product extends AbstractModel<Product>{
    public static final Product dao = new Product();
    public static final int  SALE_YES =1;
    public static final int  SALE_NO =0;
    public static final int  POST_YES =1;
    public static final int  POST_NO =0;




    public static final String ID = "id";//
    public static final String NAME = "name";//名称
    public static final String IS_POST = "is_post";//是否包邮
    public static final String WEIGHT = "weight";//重量
    public static final String PRICE = "price";//单价
    public static final String IS_SALE = "is_sale";//是否在售
    public static final String DESC = "desc";//描述
    public static final String COVER = "cover";//封面图片
    public static final String IMGS = "imgs";//图片集
    public static final String STATUS = "status";//
    public static final String CREATE_TIME = "create_time";//
    public static final String MODIFY_TIME = "modify_time";//
    public static final String CONTENT = "content";//详情内容
    public static final String COST_PRICE = "cost_price";// 成本价
    public static final String MEMBER_ID = "member_id";// 成本价
    public static final String UNIT_ID = "unit_id";// 成本价
    public static final String DELIVERY_TYPE = "delivery_type";// 成本价
    @Override
    public String tableName() {
        return "t_product";
    }

    @Override
    public String status() {
        String result="未知";
        if(getInt(STATUS)==STATUS_NORMAL){
            result="正常状态";
        }else if(getInt(STATUS)== STATUS_DEL){
            result="已删除";
        }
        return result;
    }

    public String price(){
        return PageUtil.fengToYuan(getInt(Product.PRICE))+"";
    }

    public String weight(){
        return PageUtil.g2Kg(getInt(Product.WEIGHT))+"";
    }

    public String costPrice(){
        return PageUtil.fengToYuan(getInt(Product.COST_PRICE))+"";
    }


    public String is_sale(){
        String result="未知";

        if(getInt(IS_SALE)==SALE_YES){
            result="在售";
        }else if(getInt(IS_SALE)==SALE_NO){
            result="已下架";
        }
        return result;
    }


    public String is_post(){
        String result="未知";

        if(getInt(IS_POST)==POST_YES){
            result="包邮";
        }else if(getInt(IS_POST)==POST_NO){
            result="不包邮";
        }
        return result;
    }




    public List<String> imgs(){
        return PageUtil.imgs(getStr(IMGS));
    }
}